package main

import (
	db_config2 "OldPackageTest/go_mysql/gorm_test/db_config"
	model2 "OldPackageTest/go_mysql/gorm_test/model"
	"crypto/md5"
	"encoding/hex"
	"io"
)

func genMd5(code string) string {
	Md5 := md5.New()
	_, _ = io.WriteString(Md5, code)
	return hex.EncodeToString(Md5.Sum(nil))
}

func main() {
	//now := time.Now()
	//user := model.User{Name: "zoo", Age: 30, Birthday: &now}
	//result := db_config.DB.Create(&user) // 通过数据的指针来创建

	//  创建记录，并且忽略CreateAt字段
	//result := db_config.DB.Omit( "Age").Create(&user)

	// 批量插入
	var users = []model2.User{{Name: "jinzhu1"}, {Name: "jinzhu2"}, {Name: "jinzhu3"}}
	db_config2.DB.CreateInBatches(users, len(users))

	//id := user.ID             // 返回插入数据的主键
	//rErr := result.Error        // 返回 error
	//eff := result.RowsAffected // 返回插入记录的条数
	//fmt.Println(id, rErr, eff)

}
